package com.youhui.weixin.common.exception;

import lombok.Data;

/**
 * Created by https://github.com/kuangcp on 17-10-4  上午10:04
 * 异常信息对象 错误码 错误信息
 */
@Data
public class ExceptionMap {
    private int code;
    private String info;

    private ExceptionMap(int code, String info) {
        this.code = code;
        this.info = info;
    }

    public static ExceptionMap init(int code, String info){
        return new ExceptionMap(code, info);
    }

    /**
     * 追加异常信息
     * @param info 追加的信息
     * @return 返回对象本身
     */
    public ExceptionMap append(String info){
        this.setInfo(this.getInfo()+info);
        return this;
    }

    @Override
    public String toString() {
        return "<"+code +"> " + info;
    }
}
